﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using LUStationery.Controller;
using LUStationery.Model;
using LUStationery.DAO;

public partial class CheckRequestStatus : System.Web.UI.Page
{
    RequestListControl requestcont;
    RequisitionFormControl requisitionformcont;
    Request request;
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            requestcont = new RequestListControl();
            string username = ((User)Session["user"]).UserName.ToString();
            RequestList rList = requestcont.getRequestsByUserName(username);
            gvRequestList.DataSource = rList;
            gvRequestList.DataBind();

            RequisitionFormControl rfcont = new RequisitionFormControl();
            ddlRequisitionFormID.DataSource = rfcont.getRequisitionFormsByUserName(username);
            ddlRequisitionFormID.DataTextField = "RequisitionFormID";
            ddlRequisitionFormID.DataValueField = "RequisitionFormID";
            ddlRequisitionFormID.DataBind();


        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        requestcont = new RequestListControl();
        string username = ((User)Session["user"]).UserName.ToString();
        string staffID = ((User)Session["user"]).StaffID.ToString();
        string status = ddlStatus.SelectedValue.ToString();
        string requisitionFormID = ddlRequisitionFormID.SelectedValue.ToString();
        
        //RequestList rList = requestcont.getRequestsByUserNameAndStatus(username, status);
        RequestList rList = requestcont.getRequestsByStaffIDAndStatusAndRequisitionFormID(staffID, status, requisitionFormID);
        gvRequestList.DataSource = rList;
        gvRequestList.DataBind();

        //RequestList rfIDList = requestcont.getRequisitionFormIDByUserName(username);

        
        requisitionformcont = new RequisitionFormControl();
        lbRemark.Text = requisitionformcont.getRemarkByRequisitionFormID(requisitionFormID);
        
    }
}
